from typing import List


# 1052. 爱生气的书店老板
def maxSatisfied(customers: List[int], grumpy: List[int], minutes: int) -> int:
    customers_len = len(customers)

    # 不把 minutes 考虑进去，满意的数组
    not_satisfied_customers = []

    for i in range(customers_len):
        if grumpy[i] == 0:
            not_satisfied_customers.append(0)
        else:
            not_satisfied_customers.append(customers[i])
    print(f"not_satisfied_customers:{not_satisfied_customers}")

    # 求 not_satisfied_customers 中三个连续的数的最大值
    max_index = 0
    max_num = 0
    for i in range(customers_len - minutes + 1):
        temp = 0
        for j in range(i, i + minutes):
            temp += not_satisfied_customers[j]
        if temp > max_num:
            max_index = i
            max_num = temp
    print(f"max_index:{max_index}")
    # 找到了需要在 max_index 开始抑制情绪
    re = 0
    for i in range(customers_len):
        if grumpy[i] == 0 or (max_index <= i < (max_index + minutes)):
            re += customers[i]
    return re


customers_1 = [1, 0, 1, 2, 1, 1, 7, 5]
grumpy_1 = [0, 1, 0, 1, 0, 1, 0, 1]
minutes_1 = 3
result = maxSatisfied(customers_1, grumpy_1, minutes_1)
print(f"result:{result}")

customers_1 = [4, 10, 10]
grumpy_1 = [1, 1, 0]
minutes_1 = 2
result = maxSatisfied(customers_1, grumpy_1, minutes_1)
print(f"result:{result}")
